Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mark scripts as shareable cross-origin #25380

Closed
wants to merge 1 commit into from

Conversation

nornagon
Copy link
Contributor

@nornagon nornagon commented Jan 7, 2019

This fixes an issue in Electron where errors were being incorrectly sanitized on their way to window.onerror. e.g.

process.nextTick(() => throw new Error('hi'))
window.onerror = e => console.log(e)

was printing "Script error" instead of "Uncaught Error: hi"

This is due to origin-checking logic in Blink: https://chromium.googlesource.com/chromium/src/+/71.0.3578.123/third_party/blink/renderer/core/execution_context/execution_context.cc#114

cc @joyeecheung who is blame on a lot of this code :)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. vm Issues and PRs related to the vm subsystem. labels Jan 7, 2019
@nornagon
Copy link
Contributor Author

nornagon commented Jan 7, 2019

To clarify, I'm not 100% sure this is the right approach (perhaps Electron should somehow be injecting a correct origin for these scripts?) but it does fix the issue and I'm not aware of the context for deciding to mark scripts as non-cross-origin-shareable in node (if any—it seems not relevant to most non-Electron node.js use cases)

src/module_wrap.cc Outdated Show resolved Hide resolved
@cjihrig
Copy link
Contributor

cjihrig commented Jan 7, 2019

Ping @nodejs/v8. The code changes themselves LGTM, but someone more knowledgeable about V8 should weigh in. From a quick search of the codebase, IsSharedCrossOrigin() appears to be unused by Node and V8, so maybe it's not relevant to anything but browsers.

@nornagon
Copy link
Contributor Author

nornagon commented Jan 8, 2019

Whitespace tidied.

Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I also did this when trying to fix #11893 (but that patch involved something more breaking than this)

Copy link
Contributor

@ryzokuken ryzokuken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 😉

@hashseed
Copy link
Member

hashseed commented Jan 8, 2019

Yes. This really is just a bit set for the browser. LGTM.

@antsmartian antsmartian added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 8, 2019
@antsmartian
Copy link
Contributor

@nornagon
Copy link
Contributor Author

nornagon commented Jan 8, 2019

looks to me like the test failures are flakes?

@addaleax
Copy link
Member

Yes, I think so.

Resume CI: https://ci.nodejs.org/job/node-test-pull-request/20112/

@addaleax
Copy link
Member

Landed in 817218c, thanks for the PR!

@addaleax addaleax closed this Jan 28, 2019
pull bot pushed a commit to zys-contrib/node that referenced this pull request Jan 28, 2019
PR-URL: nodejs#25380
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Yang Guo <yangguo@chromium.org>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax pushed a commit that referenced this pull request Jan 28, 2019
PR-URL: #25380
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Yang Guo <yangguo@chromium.org>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@targos targos mentioned this pull request Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. vm Issues and PRs related to the vm subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants